<?php
if(command("php")){
  if(!empty($param)){ // give them the information from the online manual at php.net
    $PHP_URL="http://www.php.net/manual/en/function.".$param.".php";
    $PHP_URL=str_replace(Array("\r","\n"),"",$PHP_URL);
    $PHP_Page=file_get_contents($PHP_URL);
    $PHP_Page=str_replace(Array("\r","\n"),"",$PHP_Page);
		$PHP_Page=str_replace(Array("<b>","</b>"),chr(2),$PHP_Page);
    $PHP_Page=str_replace("&nbsp;"," ",$PHP_Page);
    $PHP_Page=str_replace("&amp;","&",$PHP_Page);

		$PHP_Response="The command '".$param."' was not found. If you think it should be there, try searching http://php.net/";
    if(!stristr($PHP_Page,"is not in the online manual")){ // the function is in the online manual at php.net
      if(stristr($PHP_Page,"<div class=\"methodsynopsis dc-description\">")){
        $PHP_splitP1=explode("<div class=\"methodsynopsis dc-description\">",$PHP_Page);
        $PHP_P1=$PHP_splitP1[1];
        $PHP_splitP2=explode("</div>",$PHP_P1);
        $PHP_ResponseP1=strip_tags(substr($PHP_splitP2[0],3));
        if($useColors!=false){
          $PHP_Response="Syntax: ".chr(3)."2".$PHP_ResponseP1.chr(3)." Please view http://php.net/".urlencode($param)." for more details.";
        } else {
          $PHP_Response="Syntax: ".$PHP_ResponseP1." Please view http://php.net/".urlencode($param)." for more details.";
        }
      } else {
        if($useColors){
          $PHP_Response="Information on \"".chr(3)."2".$param.chr(3)."\" can be found at http://php.net/".urlencode($param);
        } else {
          $PHP_Response="Information on \"".$param."\" can be found at http://php.net/".urlencode($param);
        }
      }
    }
  }

  if(empty($PHP_Response)){ // give them the default php.net url
    $PHP_Response="The PHP homepage is at http://php.net";
  }
  while(stristr($PHP_Response,"  ")){
    $PHP_Response=str_replace("  "," ",$PHP_Response);
  }
  SendCommand("PRIVMSG $channel :$sender: $PHP_Response");
  $PHP_Response="";
}
?>